package it.antonioduca.citt;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;

public class CittBroadcastReceiver extends BroadcastReceiver {

	private final String TAG = "Citt";
	
	@Override
	public void onReceive(Context c, Intent i) {
		SharedPreferences settings = c.getSharedPreferences(c.getString(R.string.properties_filename), Context.MODE_PRIVATE); 
		boolean state = settings.getBoolean("enabled", false);
		
		Log.i(TAG, state ? "Service is ACTIVE." : "Service is NOT ACTIVE.");
		
		if(state && i.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
			Intent intent = new Intent(c, CittService.class);
	        c.startService(intent);
		}
	}

}
